﻿#pragma once

#include <DirectXMath.h>

namespace Base {

	using namespace DirectX;
	struct Vec4 {
		union
		{
			struct
			{
				float x;
				float y;
				float z;
				float w;
			};
			XMFLOAT4 data;
		};

		Vec4() {}
		Vec4(float px, float py, float pz, float pw) :x(px), y(py), z(pz), w(pw) {}

		void Set(float px, float py, float pz, float pw) {
			x = px;
			y = py;
			z = pz;
			w = pw;
		}
		Vec4& operator=(XMFLOAT4 v) {
			x = v.x;
			y = v.y;
			z = v.z;
			w = v.w;
			return *this;
		}
		Vec4 operator+(const Vec4& other) const {
			return Vec4(x + other.x, y + other.y, z + other.z, w + other.w);
		}
		Vec4 operator-(const Vec4& other) const {
			return Vec4(x - other.x, y - other.y, z - other.z, w - other.w);
		}
		Vec4 operator*(float scalar) const {
			return Vec4(x * scalar, y * scalar, z * scalar, w * scalar);
		}
		Vec4 operator/(float scalar)const;

		float Dot(const Vec4& other) const {
			return x * other.x + y * other.y + z * other.z + w * other.w;
		}


		// 解析形如 #FF00FFFF #RRGGBBAA  RGBA
		//         #FF0011   RGB
		static Vec4 ParseColor(const char* color);
	};
}